﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Position.aspx.cs" Inherits="WebPresentation.Position" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <style type="text/css">
    .style1
    {
        width: 304px;
    }
    .style2
    {
        width: 216px;
    }
    .style4
    {
            width: 450px;
        }
    .style5
    {
        width: 499px;
    }
        .style6
        {
            width: 194px;
        }
    </style>
    <script type="text/javascript" src="Scripts/jquery-1.7.2.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $('#MainContent_dtgposition td:nth-child(2), #MainContent_dtgposition th:nth-child(2)').hide();
            $("#MainContent_LinkButtonadd").click(function () {
                $("#add").toggle();
                $("#edit").hide();
                $("#delete").hide();
                return false;
            });
            $("#MainContent_LinkButtonedit").click(function () {
                $("#edit").toggle();
                $("#add").hide();
                $("#delete").hide();
                return false;
            });
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div align="center">
    
    <asp:Label ID="Label10" runat="server" Width="100%" ForeColor="Red" 
        Font-Bold="True"></asp:Label>
    
</div>
<br />
<div>
<table style="width: 100%;">
        <tr>
            <td align="center" width="33%">
                &nbsp;
                <asp:LinkButton ID="LinkButtonadd" runat="server">Add new record</asp:LinkButton>
            </td>
            <td align="center" width="34%">
                <asp:LinkButton ID="LinkButtonedit" runat="server">Edit record</asp:LinkButton>
                &nbsp;
            </td>
            <td align="center" width="33%">
                
                <asp:LinkButton ID="LinkButtondel" runat="server">Delete record</asp:LinkButton>
                
            </td>
        </tr>
    </table>
</div>
<br />
<div id="add" class="nodisplay">
    <fieldset>
    <legend>Position:</legend>
    <table style="width: 100%;">
        <tr>
            <td align="right" class="style4">
                <asp:Label ID="Label1" runat="server" Font-Bold="True" Text="Position:" 
                    Width="150px" style="text-align:left"></asp:Label>
            </td>
            <td align="left" class="style6">
                <asp:TextBox ID="txtposition" runat="server" Width="170px"></asp:TextBox>
            </td>
            <td align="center">
                <asp:RequiredFieldValidator ID="PositionValidator" runat="server" 
                    ErrorMessage="Please input Position!" ControlToValidate="txtposition" 
                    ForeColor="Red"></asp:RequiredFieldValidator>
                    <br />
                <asp:RegularExpressionValidator ID="PositionValidatorEx" runat="server" 
                    ErrorMessage="Invalid input!" ControlToValidate="txtposition" 
                    ValidationExpression="^[a-zA-Z'.\s]{1,40}$" ForeColor="Red" 
                    Enabled="False"></asp:RegularExpressionValidator>
            </td>
        </tr>
        <tr>
            <td align="right" class="style4">
                <asp:Label ID="Label2" runat="server" Font-Bold="True" Text="Position Code:" 
                    Width="150px" style="text-align:left"></asp:Label>
            </td>
            <td align="left" class="style6">
                <asp:TextBox ID="txtpositioncode" runat="server" Width="170px"></asp:TextBox>
            </td>
            <td align="center">
                <asp:RequiredFieldValidator ID="CodeValidator" runat="server" 
                    ErrorMessage="Please input position!" ControlToValidate="txtpositioncode" 
                    ForeColor="Red"></asp:RequiredFieldValidator>
                    <br />
                <asp:RegularExpressionValidator ID="CodeValidatorEx" runat="server" 
                    ErrorMessage="Invalid input!" ControlToValidate="txtpositioncode" 
                    ForeColor="Red" ValidationExpression="^[a-zA-Z0-9'.\s]{1,40}$"></asp:RegularExpressionValidator>
            </td>
        </tr>
        <tr>
            <td align="right" class="style4">
                <asp:Label ID="Label11" runat="server" Text="Label" Visible="False"></asp:Label>
            </td>
            <td align="left" class="style6">
                &nbsp;</td>
            <td align="center">
                &nbsp;</td>
        </tr>
    </table>
    <br />
    <div align="center">
        <asp:ImageButton ID="ImageButtonadd" runat="server" 
            ImageUrl="~/Images/addbutton.png" onclick="ImageButtonadd_Click" />
    </div>
</fieldset>
</div>
<div id="edit" class="nodisplay">
    <fieldset>
    <legend>Position:</legend>
    <table style="width: 100%;">
        <tr>
            <td align="right" class="style4">
                <asp:Label ID="Label3" runat="server" Font-Bold="True" Text="Position:" 
                    Width="150px" style="text-align:left"></asp:Label>
            </td>
            <td align="left" class="style6">
                <asp:TextBox ID="txPosEdit" runat="server" Width="170px"></asp:TextBox>
            </td>
            <td align="center">
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                    ErrorMessage="Please input Position!" ControlToValidate="txtposition" 
                    ForeColor="Red"></asp:RequiredFieldValidator>
                    <br />
                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                    ErrorMessage="Invalid input!" ControlToValidate="txtposition" 
                    ValidationExpression="^[a-zA-Z'.\s]{1,40}$" ForeColor="Red" 
                    Enabled="False"></asp:RegularExpressionValidator>
            </td>
        </tr>
        <tr>
            <td align="right" class="style4">
                <asp:Label ID="Label4" runat="server" Font-Bold="True" Text="Position Code:" 
                    Width="150px" style="text-align:left"></asp:Label>
            </td>
            <td align="left" class="style6">
                <asp:TextBox ID="txtCodeEdit" runat="server" Width="170px"></asp:TextBox>
            </td>
            <td align="center">
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                    ErrorMessage="Please input position!" ControlToValidate="txtpositioncode" 
                    ForeColor="Red"></asp:RequiredFieldValidator>
                    <br />
                <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" 
                    ErrorMessage="Invalid input!" ControlToValidate="txtpositioncode" 
                    ForeColor="Red" ValidationExpression="^[a-zA-Z0-9'.\s]{1,40}$"></asp:RegularExpressionValidator>
            </td>
        </tr>
        <tr>
            <td align="right" class="style4">
                <asp:Label ID="Label5" runat="server" Text="Label" Visible="False"></asp:Label>
            </td>
            <td align="left" class="style6">
                &nbsp;</td>
            <td align="center">
                &nbsp;</td>
        </tr>
    </table>
    <br />
    <div align="center">
        <asp:ImageButton ID="ImageButtonEdit" runat="server" 
            ImageUrl="~/Images/editbutton.png" onclick="ImageButtonadd_Click" />
    </div>
</fieldset>
</div>
<fieldset>
    <legend>Details:</legend>
    <div>
        
        <asp:GridView ID="dtgposition" runat="server" CellPadding="4" 
            ForeColor="#333333" GridLines="None" Width="100%" 
            AutoGenerateSelectButton="True" 
            onselectedindexchanged="dtgposition_SelectedIndexChanged" 
            AutoGenerateColumns="False" DataKeyNames="pID" DataSourceID="ObjectDataSource" 
            style="text-align: center" AllowPaging="True">
            <AlternatingRowStyle BackColor="White" />
            <Columns>
                <asp:BoundField DataField="pID" HeaderText="ID" InsertVisible="False" 
                    ReadOnly="True" SortExpression="pID" />
                <asp:BoundField DataField="pName" HeaderText="Position" 
                    SortExpression="pName" />
                <asp:BoundField DataField="pCode" HeaderText="Position Code" 
                    SortExpression="pCode" />
            </Columns>
            <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
            <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
            <SortedAscendingCellStyle BackColor="#FDF5AC" />
            <SortedAscendingHeaderStyle BackColor="#4D0000" />
            <SortedDescendingCellStyle BackColor="#FCF6C0" />
            <SortedDescendingHeaderStyle BackColor="#820000" />
        </asp:GridView>
        
        <asp:ObjectDataSource ID="ObjectDataSource" runat="server" 
            DeleteMethod="DeletePosition" InsertMethod="AddNewPosition" 
            OldValuesParameterFormatString="original_{0}" SelectMethod="GetAllPositions" 
            TypeName="BusinessLogic.PositionBO" UpdateMethod="UpdatePosition">
            <DeleteParameters>
                <asp:Parameter Name="pID" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="pName" Type="String" />
                <asp:Parameter Name="pCode" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="pName" Type="String" />
                <asp:Parameter Name="pCode" Type="String" />
                <asp:Parameter Name="pID" Type="Int32" />
            </UpdateParameters>
        </asp:ObjectDataSource>
        
    </div>
</fieldset>
</asp:Content>
